package wwl.lsf.dao;

import javax.annotation.PostConstruct;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

public class PersonService implements InitializingBean {

  private String name;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  //不会执行,因为没有注解
  public void initPostConstruct() {
    this.setName("initPostConstruct泡泡龙");
    System.out.println("this.getName() = " + this.getName());
  }

  @Override
  public void afterPropertiesSet() throws Exception {
    this.setName("afterPropertiesSet泡泡龙");
    System.out.println("this.getName() = " + this.getName());
  }

  //注解与配置文件重合,所以下面代码只会执行一次,加上上一个方法一共就会执行2次
  @PostConstruct
  public void init() {
    this.setName("init泡泡龙");
    System.out.println("this.getName() = " + this.getName());
  }

}
